﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Master/AdminDialog.Master"
    AutoEventWireup="true" CodeBehind="AdminPageDialog.aspx.cs" Inherits="Besture.UI.Admin.Dialog.AdminPageDialog" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
		<!--
        var setting = {
			data: {
				simpleData: {
					enable: true
				}
				
			}
		};

        var zNodes = <%=_json %>;

        $(document).ready(function () {
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });
		//-->
        
    	var api = frameElement.api, W = api.opener;

    	api.button({
    	    id: 'valueOk',
    	    name: '确定',
    	    callback: ok
    	});
    	
        //选中默认节点
        function DefaultSelectNodes() {
            var page = "<%= page %>";
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var node = treeObj.getNodeByParam("name",page,null);
            treeObj.selectNode(node);
        }

    	function ok() {
    	   var zTree = $.fn.zTree.getZTreeObj("treeDemo");
 
            var nodes = zTree.getSelectedNodes(true);
            //选中名称
    	    var name = "";
    	    var other = "";
            for (var i = 0; i < nodes.length; i++) {
                if(nodes[i].filetype=="1") {
                    alert("请选择页面！");
                    return false;
                }
                name = nodes[i].name;
                var parentNode = nodes[i].getParentNode();
                var parentName = "";
                if(parentNode != null) {
                    parentName = parentNode.name + "/";
                }
                
                name = "/admin/" + parentName  + name;
                break;
            }          
    	    W.jQuery("#<%=Button %>").val(name);
    	}

    	$(function() {
    	    DefaultSelectNodes();
    	});
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="content_wrap">
        <div class="zTreeDemoBackground left">
            <ul id="treeDemo" class="ztree">
            </ul>
        </div>
    </div>
</asp:Content>
